import requests

def demo():
    """通过url 来传递参数"""
    response = requests.get("http://httpbin.org/get?name=zhangsan&age=22")
    print(response.text)

def getMethod():
    '''通过get方法传递参数：'''
    data = {
        "name": "zhangsan",
        "age": 30
    }
    response = requests.get("http://httpbin.org/get", params=data)
    print(response.text)

def sendHeaders():
    """模拟发送请求头"""
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
    }
    response = requests.get("http://httpbin.org/get", headers=headers)
    print(response.text)


def sendPost():
    """发送 Post() 请求"""
    url = "http://httpbin.org/get?name=zhangsan&age=22"

    data = {
        "name": "zhangsan",
        "age": 30
    }

    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36"
    }

    response = requests.post(url, data = data, headers=headers)
    # print(response)
    print(response.text)
    print(response.content)
    print(response.status_code)
    print(response.headers)
    print(response.request)

def agentDemo():
    proxies = {
    "http": "https://175.44.148.176:9000",
    "https": "https://183.129.207.86:14002"
    }
    response = requests.get("https://www.baidu.com/", proxies=proxies)
    


if __name__ == "__main__":
    
    # getMethod()
    # sendHeaders()
    # sendPost()
    agentDemo()


    